package com.itheima.test6;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            System.out.println("请输入一个0到10的数字:");
            String s = sc.next();
            try {
                int num = Integer.parseInt(s);
                check(num);
                break;
            } catch (NumberFormatException e) {
//                e.printStackTrace();
                System.out.println("您的输入不是整数");
            } catch (MyRunTimeException e) {
//                e.printStackTrace();
                System.out.println("自定义");
                System.out.println(e.getMessage());
            }
        }
    }

    public static void check(int num) {
        if (num >= 0 && num <= 10) {
            System.out.println("您输入的数字:" + num);
        } else {
            throw new MyRunTimeException("您输入的数字不在范围内");
        }
    }
}
